package com.melody.model.convert;

import com.melody.entry.MusicCount;
import com.melody.entry.MusicInfo;
import com.melody.entry.MusicLabel;
import com.melody.model.vo.MusicDetailsVo;

import java.util.ArrayList;
import java.util.List;

/**
 * 将musicInfo和musicLabel转换成musicDetailsVo
 * */
public class MusicDetailsConvert {
    public static List<MusicDetailsVo> convert(List<MusicInfo> musicInfoList, List<MusicLabel> musicLabelList) {
        List<MusicDetailsVo> musicDetailsVoList = new ArrayList<>();

        for(MusicInfo musicInfo : musicInfoList){
            for (MusicLabel musicLabel : musicLabelList){
                if(musicInfo.getLabelId() == musicLabel.getLabelId()) {
                        MusicDetailsVo musicDetailsVo = new MusicDetailsVo();
                        // 设置音乐详情,向vo层种注入属性
                        musicDetailsVo.setMusicId(musicInfo.getMusicId());
                        musicDetailsVo.setMusicImg(musicInfo.getMusicImg());
                        musicDetailsVo.setMusicUrl(musicInfo.getMusicUrl());
                        musicDetailsVo.setMusicName(musicInfo.getMusicName());
                        musicDetailsVo.setSinger(musicInfo.getSinger());
                        musicDetailsVo.setLabelId(musicInfo.getLabelId());
                        musicDetailsVo.setLabel(musicLabel.getLabel());
                        musicDetailsVo.setMusicTime(musicInfo.getMusicTime());
                        musicDetailsVo.setCreateTime(musicInfo.getCreateTime());
                        musicDetailsVo.setUpdateTime(musicInfo.getUpdateTime());
                        musicDetailsVo.setIsDelete(musicInfo.getIsDelete());

                        musicDetailsVoList.add(musicDetailsVo);
                }

            }
        }
        return musicDetailsVoList;
    }
}
